package com.jingdianjichi.subject.infra.basic.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jingdianjichi.subject.infra.basic.entity.SubjectInfo;
import com.jingdianjichi.subject.infra.basic.service.SubjectInfoService;
import com.jingdianjichi.subject.infra.basic.mapper.SubjectInfoMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
* @author 20432
* @description 针对表【subject_info(题目信息)】的数据库操作Service实现
* @createDate 2025-10-03 16:36:37
*/
@Service
@Slf4j
public class SubjectInfoServiceImpl extends ServiceImpl<SubjectInfoMapper, SubjectInfo>
    implements SubjectInfoService{

    @Resource
    private SubjectInfoMapper subjectInfoMapper;


    @Override
    public int pageQueryConut(Integer subjectDifficult, Long labelId, Long categoryId) {
        return subjectInfoMapper.pageQueryConut(subjectDifficult, labelId, categoryId);
    }

    @Override
    public List<SubjectInfo> pageQuery(List<Long> subjectIds, int start, Integer pageSize,Integer difficult) {
        List<SubjectInfo> subjectInfoList = subjectInfoMapper.pageQuery(subjectIds, start, pageSize ,difficult);
        log.info("分页查询题目列表Mapper: {}", subjectInfoList);
        if(subjectInfoList != null && !subjectInfoList.isEmpty()){
            return subjectInfoList;
        }
        return Collections.emptyList();
    }

    @Override
    public SubjectInfo queryById(Long id) {
        SubjectInfo subjectInfo = subjectInfoMapper.selectById(id);
        return subjectInfo;

    }

    @Override
    public void insert(SubjectInfo subjectInfo) {
        subjectInfoMapper.insertMultiple(subjectInfo);
    }
}




